$( document ).on( "pagecreate", "#sendReview", function( event ) {
//	$("input").parent().remove();
	$("#sendReview_textarea").val("");
});
var reviewType='0';
$( document ).on( "pageshow", "#sendReview", function( event ) {
	$("#sendReview_textarea").css({"height":"200px"});
	access_token=getParameterByName("access_token",getLocationUrl(event));//getQueryString("access_token");
	var empId=getParameterByName("empId",getLocationUrl(event) );
	
//	$( document ).on( "keyup", "#sendReview_textarea", function( event ) {
//		changeText();
//	});
	$("#sendReview_textarea").on("keyup",function (){
		changeText();
	});
	$("#sendReview_submit").on("click",function (){
		to_sendReview();
	});
	//匿名、实名切换
	//tap 当用户敲击某元素时触发
//	$( document ).on( "click", "[name='radioBut']", function( event ) {
	$("[name='radioBut']").on("click",function (){
		var thisClassName = this.className;
		var another;
		var childrenNode = $(".circle").children();
		if('circle_empty' == thisClassName){
			another = $(".circle");
			another.children().remove();
			another.attr('class','circle_empty');
			$(this).attr('class','circle');
			$(childrenNode).prependTo(".circle");
			reviewType=$(this).attr("reviewType");
		}
	});
	//表情选择
//	$( document ).on( "click", "#bqsendReview", function( event ) {
	$("#bqsendReview").on("click",function (){
		$("#bqsendReview").manhuaHtmlArea({
			Event : "click",
			Left : -22,
			Top : 23,			
			id : "sendReview_textarea",
			callbackFun:function (){
				changeText();
			}
		});
	});
	//text输入长度处理
	function changeText(){
		var len = $("#sendReview_textarea").val().length; 
		var show = "" + len + "/140"; 
		$("#name").html(show); 
	}
	function to_sendReview(){
		var content=$("#sendReview_textarea").val();
		if(content==undefined || content=="" || content.length<5){
			alert_wx("fail","发送内容为空或最低长度不足");
			return false;
		}
		$("#sendReview_submit").off();//删除单击事件
		$.ajax({
		  	url: rootPath+"/review/addReview.do",
		  	type: "POST",
		  	dataType: "text",
			data: "access_token="+access_token+"&toEmpId="+empId+"&content="+content+"&criticsType="+reviewType,
		  	success: function( response ) {
		  		var data=$.parseJSON(response);
		  		
				if(data.state=="200"){
					$.lt_alert({
						type: 'success',
						right_close:true,
						content: '红花赠送成功！<br>（赠人玫瑰，手有余香，恭喜获得花瓣一片）'
					});
					$("#sendReview_textarea").val('');
					$("#name").html("0/140"); 
				}else{
					alert_wx("fail",data.msg);
				}
		  	}
		});
	}
});
